package io.datajek.springbasics.movierecommendersystem.lesson11;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
//@Primary
@Qualifier("CBF")
public class ContentBasedFilter implements Filter {

	public String[] getRecommendations(String movie) {
		//基于内容的过滤器的逻辑
		
		//返回电影推荐
		return new String[] {"Happy Feet","Ice Age","Shark Tale"};
	}

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	public ContentBasedFilter(){
		super();
		logger.info("In ContentBasedFilter constructor method");
	}

	@PostConstruct
	private void postConstruct(){
//		将电影加载到缓存里
		logger.info("In ContentBasedFilter constructor method");
	}

	@PreDestroy
	private void preDestroy(){
//		从缓存中清理电影
		logger.info("In ContentBasedFilter preDestroy method");
	}

}
